package com.qujia.station.controller;


import com.qujia.common.core.controller.BaseController;
import com.qujia.common.core.domain.AjaxResult;
import com.qujia.station.domain.NonOilCategory;
import com.qujia.station.service.INonOilCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


/**
 * 非油品分类Controller
 *
 * @author zhongxin
 * @date 2023-08-14
 */
@Api("非油品分类接口")
@RestController
@RequestMapping("/nonOilCategory")
public class NonOilCategoryController extends BaseController
{
    @Autowired
    private INonOilCategoryService nonOilCategoryService;

    /**
     * 查询非油品分类树
     */
    @PostMapping("/getNonOilCategoryTree")
    @ApiOperation("查询非油品分类树")
    public AjaxResult getNonOilCategoryTree(@RequestBody NonOilCategory nonOilCategory)
    {
        NonOilCategory nonOilCategoryTree = nonOilCategoryService.getNonOilCategoryTree(nonOilCategory);

        return AjaxResult.success(nonOilCategoryTree);
    }


    /**
     * 通过id查询非油品分类
     */
    @GetMapping("/queryById/{categoryId}")
    @ApiOperation("通过id查询非油品分类")
    public AjaxResult queryById(@PathVariable Long categoryId)
    {
        return AjaxResult.success(nonOilCategoryService.queryById(categoryId));
    }

    /**
     * 修改非油品分类
     */
    @ApiOperation("修改非油品分类")
    @PostMapping("/update")
    public AjaxResult update(@RequestBody NonOilCategory nonOilCategory)
    {
        return toAjax(nonOilCategoryService.update(nonOilCategory));
    }



    /**
     * 删除非油品分类
     */
    @ApiOperation("删除非油品分类")
    @ApiImplicitParam(name = "categoryIds",dataType = "Long",value = "categoryId数组")
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody List<Long> categoryIds)
    {
        return toAjax(nonOilCategoryService.delete(categoryIds));
    }


    /**
     * 新增非油品分类树
     */
    @PostMapping("/insert")
    @ApiOperation("新增非油品分类")
    public AjaxResult insert(@RequestBody NonOilCategory nonOilCategory)
    {
        return toAjax(nonOilCategoryService.insertCategory(nonOilCategory));
    }

}
